import javax.swing.*;
import java.awt.*;

public class MyGridWindow extends JPanel {
	
	private static final long serialVersionUID = 1L;
	
	int myRows;
	int myCols;
	MyCell[][] myCells;
	
	MyGridWindow(int rows, int cols) {
		
		this.myRows = rows;
		this.myCols = cols;
		

		setLayout(new GridLayout(myRows, myCols));
		myCells = new MyCell[myRows][myCols];
		
		for (int i = 0; i < myRows ; i++) {
			for(int j = 0; j < myCols ; j++) {
				
				myCells[i][j] = new MyCell();
				
				add(myCells[i][j]);
			}
		}
	}
	
	public void paintCell (int robotRow, int robotCol, int color) {
		
		if (color == 0) { // EMPTY PASSED CELL
			myCells[(10 -robotRow)][robotCol].setColor(Color.GREEN);
		} else if (color == 1) { // FIRST ROOM PEASENT
			myCells[(10 -robotRow)][robotCol].setColor(Color.BLACK);
		} else if (color == 2){ // SECOND ROOM PEASENT
			myCells[(10 -robotRow)][robotCol].setColor(Color.GRAY);
		} else if (color == 3){ // KING
			myCells[(10 -robotRow)][robotCol].setColor(Color.YELLOW);
		} 
		myCells[(10 -robotRow)][robotCol].doRefresh();
	}
	
	public void paintCellLevel2 (int robotRow, int robotCol, int color) {
		
		if (color == 4){ // PRINCESS
			myCells[(2 -robotRow)][robotCol].setColor(Color.ORANGE);
		} else if (color == 5){ // DRAGON
			myCells[(2 -robotRow)][robotCol].setColor(Color.RED);
		} else if (color == -10) {
			myCells[(2 -robotRow)][robotCol].setColor(Color.BLUE);
		}
		myCells[(2 -robotRow)][robotCol].doRefresh();
	}
	
}
